package com.angis.fx.activity.service;

import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import android.widget.Toast;

import com.angis.fx.data.ContextInfo;
import com.angis.fx.handler.login.UpdateHandler;

public class UploadLoginInfoService extends Service {

	@Override
	public void onCreate() {
		super.onCreate();
//		Intent lIntent = 
		
	}

	@Override
	public IBinder onBind(Intent intent) {
		return null;
	}

	@Override
	public void onStart(Intent intent, int startId) {
		super.onStart(intent, startId);
		Toast.makeText(this, "正将登陆信息上传至服务器!", Toast.LENGTH_LONG).show();
		try {
			int flag = UpdateHandler.uploadLoginInfo(this, (ContextInfo)intent.getExtras().get("contextinfo"));
			Thread.sleep(1000);
			if(flag == -1) {
				Toast.makeText(this, "服务器连接错误!", Toast.LENGTH_SHORT).show();
			}else if(flag == 0){
				Toast.makeText(this, "登陆信息上传错误!", Toast.LENGTH_SHORT).show();
			}else if(flag == 1){
				Toast.makeText(this, "登陆信息上传完成!", Toast.LENGTH_SHORT).show();
			}
		} catch (InterruptedException e) {} finally {this.stopSelf();}
	}

}
